package DemoText;

/**
 * 验证回文串
 */
public class LeetCodeLCR018 {
    public boolean isPalindrome(String s) {
        s = s.toLowerCase();
        char[] ss = s.toCharArray();
        int left = 0, right = ss.length - 1;
        while (left < right) {
            while ((left < right) && ((ss[left] > 'z' || ss[left] < '0') || (ss[left] < 'a' && ss[left] > '9'))) left++;
            while ((left < right) && ((ss[right] > 'z' || ss[right] < '0') || (ss[right] < 'a' && ss[right] > '9'))) right--;
            if (ss[left] != ss[right]) return false;
            left++; right--;
        }
        return true;
    }
}
